package cn.pet_know.common.result;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@Getter
@Setter
public class R<T> {
    private int code;
    private String msg;
    private T data;
    private String timeStamp;

    public static <T> R<T> ok(T data){
        R<T> r = new R<>();
        r.setCode(200);
        r.setData(data);
        r.setTimeStamp(String.valueOf(System.currentTimeMillis()));
        return r;
    }
    public static <T> R<T> fail(String msg,int errorCode){
        R<T> r = new R();
        r.setCode(errorCode);
        r.setMsg(msg);
        r.setData(null);
        r.setTimeStamp(String.valueOf(System.currentTimeMillis()));
        return r;
    }

}